{{define "Title"}}按工单查询{{end}}
{{define "Content"}}

<script type=text/javascript src="/js/splitPage.js"></script>
<script type=text/javascript src="/js/woPerPage.js"></script>
<script type=text/javascript src="/js/downloadwo.js"></script>
<script type=text/javascript src="/js/tablestyle.js"></script>

<div class="container-fluid">
<form class="form-horizontal" action="/querywo" method="POST">
  <fieldset>
    <legend><b>按工单查询</b></legend>
    <div class="control-group">
      <label class="control-label">工单&nbsp;</label>
      <div class="control">
        <input type="text" class="input-large" id="wono" name="wono" style="font-weight: bold; text-transform:uppercase; background-color: #FFFFD0;" maxlength="30"> <b style="color: red">*</b>
      </div>
    </div>
    <div class="form-actions">
      <button type="submit" class="btn btn-primary">查询</button>
    </div>
  </fieldset>
</form>
</div>

{{if .ssn_range.RangeFrom}}
<div class="control-group">
  <label class="control-label">工单序号范围: <b>{{.ssn_range.RangeFrom | html}} - {{.ssn_range.RangeTo | html}}</b></label>
</div>
{{end}}

{{if .wo_main.Wono}}
<div class="content-box">
  <div class="content-box-header">
    <p style="font-size: 16px;">&nbsp;&nbsp;<b>工单</b></p>
  </div>
<div class="content-box-content">
<table id="tbl_main" width="100%" border="1" cellspacing="0" cellpadding="0">
  <thead>
    <tr>
      <th>工单</th>
      <th>类型</th>
      <th>版本</th>
      <th>物料</th>
      <th>描述</th>
      <th>数量</th>
      <th>制程</th>
      {{if eq .ProductionLine "SFPRD06"}}
        <th>批次</th>
      {{else}}
        <th>备注</th>
      {{end}}      
    </tr>
  </thead>
  <tbody>
    <tr>
      <td id="main_won" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.wo_main.Wono | html}}</td>
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.wo_main.Wotype | html}}</td>
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.wo_main.Version | html}}</td>
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px"><a href="/queryitem?q={{.wo_main.Item | html}}">{{.wo_main.Item | html}}</a></td>
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.wo_main.Desc | html}}</td>
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.wo_main.Qty | html}}</td>
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px"><a href="/routing?q={{.wo_main.Route | html}}">{{.wo_main.Route | html}}</a></td>
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.wo_main.Remark | html}}</td>
    </tr>
  </tbody>
</table>
</div>
</div>
{{end}}

{{if .prod_range.RangeFrom}}
<div class="control-group">
  <label class="control-label">生产日期区间: &lt;<b>{{.prod_range.RangeFrom | html}}</b>&gt; - &lt;<b>{{.prod_range.RangeTo | html}}</b>&gt;</label>
</div>
{{end}}

{{if .total_sta}}
<div class="content-box">
    <div class="content-box-header">
      <p style="font-size: 16px;">&nbsp;&nbsp;<b>生产数据</b></p>
    </div>
<table id="tbl_ls" border="1" cellspacing="0" cellpadding="0" style="font-size:100%">
  <thead>
    <tr>
      <th rowspan='1' style="text-align:center">站点</th>
      <th rowspan='1' style="text-align:center">投入</th>
      <th rowspan='1' style="text-align:center">产出</th>
      <th rowspan='1' style="text-align:center">在制</th>
      <th rowspan='1' style="text-align:center">不良</th>
      <th rowspan='1' style="text-align:center">F3</th>
      <th rowspan='1' style="text-align:center">F2</th>
      <th rowspan='1' style="text-align:center">F1</th>
      <th rowspan='1' style="text-align:center">P3</th>
      <th rowspan='1' style="text-align:center">P2</th>
      <th rowspan='1' style="text-align:center">P1</th>
      <th rowspan='1' style="text-align:center">P</th>
      <th rowspan='1' style="text-align:center">FPY</th>
      <th rowspan='1' style="text-align:center">RPY1</th>
      <th rowspan='1' style="text-align:center">RPY2</th>
      <th rowspan='1' style="text-align:center">RPY3</th>
      <th rowspan='1' style="text-align:center">RPY</th>
      <th rowspan='1' style="text-align:center">PY</th>
    </tr>
  </thead>
  <tbody id="group_one">
  {{$curwo := .wo_main.Wono}}
  {{range .total_sta}}
  <tr>
    <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Station | html}}</td>
    {{if gt .Input 0}}
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Input | html}}</td>
    {{else}}
      <td fieldset style="color: #666666; border-style: groove; font-size: 14px">0</td>
    {{end}}
    {{if gt .Output 0}}
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.Output | html}}</td>
    {{else}}
      <td fieldset style="color: #666666; border-style: groove; font-size: 14px">0</td>
    {{end}}
    {{if gt .Inprocess 0}}
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px"><a href="/inprocdetail?nm={{.Inprocess | html}}&wo={{$curwo | html}}&st={{.Station | html}}&im=All">{{.Inprocess | html}}</a></td>
    {{else}}
      <td fieldset style="color: #666666; border-style: groove; font-size: 14px">0</td>
    {{end}}
    {{if gt .FailUnit 0}}
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px"><a href="/infaildetail?nm={{.FailUnit | html}}&wo={{$curwo | html}}&st={{.Station | html}}&im=All">{{.FailUnit | html}}</a></td>
    {{else}}
      <td fieldset style="color: #666666; border-style: groove; font-size: 14px">0</td>
    {{end}}
    {{if gt .F3Unit 0}}
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.F3Unit | html}}</td>
    {{else}}
      <td fieldset style="color: #666666; border-style: groove; font-size: 14px">0</td>
    {{end}}
    {{if gt .F2Unit 0}}
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.F2Unit | html}}</td>
    {{else}}
      <td fieldset style="color: #666666; border-style: groove; font-size: 14px">0</td>
    {{end}}
    {{if gt .F1Unit 0}}
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.F1Unit | html}}</td>
    {{else}}
      <td fieldset style="color: #666666; border-style: groove; font-size: 14px">0</td>
    {{end}}
    {{if gt .P3Unit 0}}
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.P3Unit | html}}</td>
    {{else}}
      <td fieldset style="color: #666666; border-style: groove; font-size: 14px">0</td>
    {{end}}
    {{if gt .P2Unit 0}}
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.P2Unit | html}}</td>
    {{else}}
      <td fieldset style="color: #666666; border-style: groove; font-size: 14px">0</td>
    {{end}}
    {{if gt .P1Unit 0}}
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.P1Unit | html}}</td>
    {{else}}
      <td fieldset style="color: #666666; border-style: groove; font-size: 14px">0</td>
    {{end}}
    {{if gt .PUnit 0}}
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.PUnit | html}}</td>
    {{else}}
      <td fieldset style="color: #666666; border-style: groove; font-size: 14px">0</td>
    {{end}}
    <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.FpyYield | html}}</td>
    <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.RpYield1 | html}}</td>
    <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.RpYield2 | html}}</td>
    <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.RpYield3 | html}}</td>
    <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.RpYield | html}}</td>
    <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.PyYield | html}}</td>
  </tr>
  {{end}}
  <tr>
    <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.totals.Station | html}}</td>
    {{if gt .totals.Input 0}}
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.totals.Input | html}}</td>
    {{else}}
      <td fieldset style="color: #666666; border-style: groove; font-size: 14px">0</td>
    {{end}}
    {{if gt .totals.Output 0}}
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.totals.Output | html}}</td>
    {{else}}
      <td fieldset style="color: #666666; border-style: groove; font-size: 14px">0</td>
    {{end}}
    {{if gt .totals.Inprocess 0}}
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px"><a href="/inprocdetail?nm={{.totals.Inprocess | html}}&wo={{$curwo | html}}&st=All&im=All">{{.totals.Inprocess | html}}</a></td>
    {{else}}
      <td fieldset style="color: #666666; border-style: groove; font-size: 14px">0</td>
    {{end}}
    {{if gt .totals.FailUnit 0}}
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px"><a href="/infaildetail?nm={{.totals.FailUnit | html}}&wo={{$curwo | html}}&st=All&im=All">{{.totals.FailUnit | html}}</a></td>
    {{else}}
      <td fieldset style="color: #666666; border-style: groove; font-size: 14px">0</td>
    {{end}}
    {{if gt .totals.F3Unit 0}}
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.totals.F3Unit | html}}</td>
    {{else}}
      <td fieldset style="color: #666666; border-style: groove; font-size: 14px">0</td>
    {{end}}
    {{if gt .totals.F2Unit 0}}
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.totals.F2Unit | html}}</td>
    {{else}}
      <td fieldset style="color: #666666; border-style: groove; font-size: 14px">0</td>
    {{end}}
    {{if gt .totals.F1Unit 0}}
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.totals.F1Unit | html}}</td>
    {{else}}
      <td fieldset style="color: #666666; border-style: groove; font-size: 14px">0</td>
    {{end}}
    {{if gt .totals.P3Unit 0}}
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.totals.P3Unit | html}}</td>
    {{else}}
      <td fieldset style="color: #666666; border-style: groove; font-size: 14px">0</td>
    {{end}}
    {{if gt .totals.P2Unit 0}}
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.totals.P2Unit | html}}</td>
    {{else}}
      <td fieldset style="color: #666666; border-style: groove; font-size: 14px">0</td>
    {{end}}
    {{if gt .totals.P1Unit 0}}
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.totals.P1Unit | html}}</td>
    {{else}}
      <td fieldset style="color: #666666; border-style: groove; font-size: 14px">0</td>
    {{end}}
    {{if gt .totals.PUnit 0}}
      <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.totals.PUnit | html}}</td>
    {{else}}
      <td fieldset style="color: #666666; border-style: groove; font-size: 14px">0</td>
    {{end}}
    <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.totals.FpyYield | html}}</td>
    <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.totals.RpYield1 | html}}</td>
    <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.totals.RpYield2 | html}}</td>
    <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.totals.RpYield3 | html}}</td>
    <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.totals.RpYield | html}}</td>
    <td fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px">{{.totals.PyYield | html}}</td>
  </tr>
  </tbody>
</table>
</div>
{{end}}

{{if .wo_ls}}
<div class="content-box">
  <div class="content-box-header">
    <p style="font-size: 16px;">&nbsp;&nbsp;<b>工单明细</b></p>
  </div>
<div class="content-box-content">
<span id=obj1 style="color: black">
<table id="tbl_ls" border="1" cellspacing="0" cellpadding="0">
  <thead>
    <tr>
      <th>索引</th>
      <th>产品序号</th>
      <th>站点</th>
      <th>结果</th>
      <th>不良代码</th>
    </tr>
  </thead>
  <tbody id="group_one">
  {{range .wo_ls}}
  <tr>
    {{if eq .Result "PASS" "NDF"}}      
      <td id="detail_idx" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px" width="80">{{.Index | html}}</td>
      <td id="detail_ssn" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px" width="240"><a href="/queryssn?q={{.Serial | html}}">{{.Serial | html}}</a></td>
      <td id="detail_sta" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px" width="300">{{.Curr | html}}</td>
      <td id="detail_rst" fieldset style="background: #00CC00; border-style: groove; font-weight: bold; font-size: 14px" width="100">{{.Result | html}}</td>
      <td id="detail_fcd" fieldset style="color: #666666; border-style: groove; font-weight: bold; font-size: 14px" width="160">{{.Failcode | html}}</td>
    {{else}}
      <td id="detail_idx" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px" width="80">{{.Index | html}}</td>
      <td id="detail_ssn" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px" width="240"><a href="/queryssn?q={{.Serial | html}}">{{.Serial | html}}</a></td>
      <td id="detail_sta" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px" width="300">{{.Curr | html}}</td>
      <td id="detail_rst" fieldset style="background: #E00000; color: #EFF000; border-style: groove; font-weight: bold; font-size: 14px" width="100">{{.Result | html}}</td>
      <td id="detail_fcd" fieldset style="background: #EFF000; border-style: groove; font-weight: bold; font-size: 14px" width="160">{{.Failcode | html}}</td>
    {{end}}
  </tr>
  {{end}}
  </tbody>
</table>
</span>
</div>
</div>
<div>
  <input type=button id="download" value="Download..." style="font-weight: bold;">
</div>
<span id="spanFirst"><img id='first' src="/images/FirstPageImageUrl.gif" onclick="onFirstClick();"/></span> <span id="spanPre"><img id='prev' src="/images/PreviousPageImageUrl.gif" onclick="onPrevClick();"/></span> <span id="spanNext"><img id='next' src="/images/NextPageImageUrl.gif" onclick="onNextClick();"/></span> <span id="spanLast"><img id='last' src="/images/LastPageImageUrl.gif" onclick="onLastClick();"/></span> 当前页: <span id="spanPageNum">{{.curr_page}}</span> / 总页数: <span id="spanTotalPage">{{.total_page}}</span> <span><input id="specialnum" style="width: 60px; color: blue; font-size: 14px; font-weight: bold;" type="text" onkeydown="onSpecialKeydown();"></span><span id="GotoSpecial" style="font-size: 14px; font-weight: bold; cursor:hand; text-decoration:underline; color: #57a000;" onclick="onSpecialClick();">Goto!</span>
<input type=hidden id="wonos" value="{{.downloads | html}}">
<input type=button id="wossnquery" value="ff" style="display:none">
{{end}}

{{end}}